package com.lagou;

import com.lagou.dao.IUserdao;
import com.lagou.io.Resources;
import com.lagou.pojo.User;
import com.lagou.sqlSession.SqlSession;
import com.lagou.sqlSession.SqlSessionFactory;
import com.lagou.sqlSession.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.InputStream;



public  class IPersistenceTest {

        @Test
        public void test() throws Exception {
            InputStream resourceAsSteam = Resources.getResourceAsSteam("sqlMapConfig.xml");
            SqlSessionFactory build = SqlSessionFactoryBuilder.build(resourceAsSteam);
            SqlSession sqlSession = build.OpenSession();

           //调用
            User user = new User();
            user.setId(1+"");
            user.setUsername("lilei");
           /*  List<User> user1 = sqlSession.selectList("user.selectList");
            System.out.println(user1);*/
            IUserdao userdao = sqlSession.getMap(IUserdao.class);
           userdao.addUser(user);
        }
    }

